{extend name="index/index" /}
{block name="main"}
<div style="height:50px;"></div>

<h1>简易详情页 会员页</h1>
<button class="btn btn-danger btn-lg book-btn " book-id="{$id}">加入书架</button>


<script>
   $(function(){
       //    弹框参数
       toastr.options = {
           closeButton: true,
           progressBar: true,
           timeOut: "2000",
           positionClass: "toast-top-right"
       };
   //    触发加入书架
       $('.book-btn').click(function(){
           var book_id = $(this).attr('book-id');
           if(confirm('确定加入书架？')){
              do_bookmarker(book_id);
           }
       })
   })

    function do_bookmarker(id){
       $.ajax({
           type:'get',
           url:'/bookmarkers/'+id,
           dataType : 'json',
           success:function(data){
               if(data.status){
                   toastr.success(data.info);
               }else{
                   toastr.error(data.info, 'WARING!!!!!!:');
               }
           },
           error:function(data){
               alert('AJAX操作失败');
           }
       })
    }
</script>


{/block}